<extend name="common:base" />
<block name="content">
    <div id="header">
        <div class="header">
            <h1 class="tit">{$site_title}</h1>
            <!--<p class="goback">-->
                <!--<a class="return" href="javascript:history.go(-1);">返回</a>-->
            <!--</p>-->
            <!--<p class="more"><a class="share" href=""></a></p>-->
        </div>
    </div>
    <form action="{:U('Setting/self_detail')}" method="post" id="editself_form" enctype="multipart/form-data">
        <div class="person-msg">
            <div class="person-top">
                <div class="heade-poto">
                    <p class="header-name">头像</p>
                    <div class="boxlist">
                        <if condition="$self['avatar'] neq ''">
                            <img onclick="getElementById('file').click()" src="{$self['avatar']}">
                            <else/>
                            <img onclick="getElementById('file').click()" src="__PUBLIC__/images/default.png">
                        </if>

                    </div>
                    <input type="file" name='file' id="file"/>
                </div>


                <div class="login-name">
                    <p class="login">代理名称</p>
                    <input type="text" name="agent_name" class="form-input" id="agent_name" value="{$self['agent_name']}"/>
                </div>
                <div class="login-name">
                    <p class="birthday">性别</p>
                    <select name="sex" class="form-select" id="sex">
                        <option value="0">保密</option>
                        <option value="1" <if condition="$self['sex'] eq 1">selected</if>>男</option>
                        <option value="2" <if condition="$self['sex'] eq 2">selected</if>>女</option>
                    </select>
                </div>
                <div class="login-name">
                    <p class="birthday">手机号</p>
                    <input type="number" readonly class="form-input" value="{$self['mobile']}" style="border:0;"/>
                </div>
                <div class="person-weChat">
                    <p class="chat-code">微信二维码</p>
                    <if condition="$self['wx_ewm'] neq ''">
                        <a href="{:U('Setting/upload_code',array('t' =>'ewm'))}" class="ewm">
                            <img src="{:C('__STATIC__')}{$theme}/Static/img/ewm.jpg"/>
                        </a>
                        <else/><a class="no_ewm" href="{:U('Setting/upload_code',array('t'=>'ewm'))}">去上传</a>
                    </if>
                </div>
                <div class="weChat-collection">
                    <p class="collection">微信收款码</p>
                    <if condition="$self['wx_skm'] neq ''">
                        <a href="{:U('Setting/upload_code',array('t' =>'skm'))}" class="ewm">
                            <img src="{:C('__STATIC__')}{$theme}/Static/img/ewm.jpg"/>
                        </a>
                        <else/><a class="no_ewm" href="{:U('Setting/upload_code',array('t'=>'skm'))}">去上传</a>
                    </if>
                </div>

                <div class="person-pet">
                    <p class="pet">个人签名</p>
                    <textarea placeholder="这个人很懒，什么都没有留下。" class="signature" name="signature" id="signature">{$self['signature']}</textarea>
                </div>
            </div>
        </div>
        <div class="person-form">
            <span id="editself">保存</span>
        </div>
    </form>

</block>
<block name="CSS">
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/agentview.css" />
</block>
<block name="JS">
    <script type="text/javascript" src="__PUBLIC__/Admin/static/ext/js/jquery.form.js"></script>
    <script type="text/javascript">
        $(function(){

            //图片预览
            $('#file').change(function() {
                var file = $('#file').get(0).files[0];
                var size = file.size;
                var fileSize=Math.round(size/1024*100)/100;
                if (fileSize > 1024) {
                    layer.msg('图片不得超过1024KB!', {icon: 2, time: 1000});
                    return false;
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload=function(e){
                    $('.boxlist img').attr('src', e.target.result);
                }
            });

            //保存(ajaxSubmit能传文件(图片),ajax不行)
            $('#editself').click(function(e) {
                 $("#editself_form").ajaxSubmit({
                    url: "{:U('Setting/self_detail')}",
                    type:'post',
                    data: {
                        'img': $('#file').val(),
                        'agent_name': $('#agent_name').val(),
                        'sex': $('#sex').val(),
                        'signature': $('#signature').val()
                    },
                    success: function(msg) {
                        if (msg == 'success') {
                            layer.msg('修改成功!', {icon: 1, time: 1000});
                            setTimeout(function() {
                                window.location.href = document.referrer;
                            },500)
                        }
                    }
                 });
            });
            
        });


    </script>
</block>








